<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <!-- <link rel='stylesheet' href='/stylesheets/style.css' /> -->
    <%- include common %>
  </head>
  <body>
    <%- include('head',{title:'home',username:username}) %>
    <div class="container">
      <h3><%= title %></h3>
      <p>Welcome to <%= title %></p>
    <%  if(username){ %>
        <p>欢迎你：<%- username %></p>
        <p>当前时间：<span id="currentTime"></span></p>
        <button class="btn btn-danger" onclick="location.href='/logout'">注销登录</button>
    <%  }else{  %>
        <button class="btn btn-primary" onclick="location.href='/login'">立即登录</button>
        <button class="btn btn-success" onclick="location.href='/register'">马上注册</button>
   <%   } %>
    </div>
    <%- include foot %>
  </body>
  <script>
    window.onload = function(){
      initTime();
      setInterval(initTime,1000);
    }

    function initTime(){
      var time = new Date();
      var year = time.getFullYear();
      var month = time.getMonth() + 1;
      var day = time.getDate();
      var hour = time.getHours();
      var min = time.getMinutes();
      var sec = time.getSeconds();
      $('#currentTime').text(`${year}-${month>9?month:`0${month}`}-${day>9?day:`0${day}`} ${hour>9?hour:`0${hour}`}:${min>9?min:`0${min}`}:${sec>9?sec:`0${sec}`}`)
    }
  </script>

</html>
